<HTML><HEAD><TITLE>term_variables(?Term, -VarList)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Term Manipulation</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>term_variables(?Term, -VarList)</H1>
Succeeds if VarList is the list of all variables in Term.


<DL>
<DT><EM>Term</EM></DT>
<DD>Prolog term.
</DD>
<DT><EM>VarList</EM></DT>
<DD>List or variable.
</DD>
</DL>
<H2>Description</H2>
   This predicate collects all the variables inside Term into the list
   VarList.  Every variable occurs only once in VarList, even if it occurs
   several times in Term.  The order of the variables in the list is not
   specified.  As usual, attributed variables are also considered variables.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>term_variables(?, -) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>VarList instantiated but not to a list.
</DL>
<H2>Examples</H2>
<PRE>
Success:
    term_variables(atom, []).
    term_variables(Term, L).       % gives L = [Term]
    term_variables(f(a,B,c), L).   % gives L = [B]
    term_variables([X,Y,Z], L).    % gives L = [Z,Y,X]
    term_variables([X,Y,X], L).    % gives L = [Y,X]
    term_variables(s(X{a}), L).    % gives L = [X{a}]

Fail:
    term_variables(f(a,B,c), []).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/typetest/nonground-1.html">nonground / 1</A>, <A HREF="../../kernel/typetest/nonground-2.html">nonground / 2</A>, <A HREF="../../kernel/typetest/nonground-3.html">nonground / 3</A>, <A HREF="../../kernel/typetest/nonvar-1.html">nonvar / 1</A>, <A HREF="../../kernel/typetest/var-1.html">var / 1</A>
</BODY></HTML>
